//
//  ViewController.m
//  MoreLanguageDemo
//
//  Created by 河南动力无限科技有限公司 on 2018/3/17.
//  Copyright © 2018年 Sheldon. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

//参考链接：http://www.devashen.com/blog/2016/01/18/localized03/
//参考链接：https://www.jianshu.com/p/e97584e7ca13

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = NSLocalizedStringFromTable(@"titleLabel", @"MoreLanguageDemo", nil);
    
    NSString *path = [[NSBundle mainBundle] pathForResource:@"en" ofType:@"lproj"];
    NSString *showValue = [[NSBundle bundleWithPath:path] localizedStringForKey:@"titleLabel" value:nil table:@"MoreLanguageDemo"];
    NSLog(@"result: %@", showValue);
    
    
    
    NSString *path1 = [[NSBundle mainBundle] pathForResource:@"zh-Hans" ofType:@"lproj"];
    NSString *showValue1 = [[NSBundle bundleWithPath:path1] localizedStringForKey:@"titleLabel" value:nil table:@"MoreLanguageDemo"];
    NSLog(@"result: %@", showValue1);
   
    //下面的正则表达式在Xcode中OC中使用，可以找到@""里面的中文字符串；
    //若是在Swift版本中使用需要去掉@,变为("[^"]*[\u4E00-\u9FA5]+[^"\n]*?")\s*
    //中文字符串匹配正则表达式：(@"[^"]*[\u4E00-\u9FA5]+[^"\n]*?")\s*
    
    NSLog(@"%@哈哈，。", NSLocalizedStringFromTableInBundle(@"titleLabel", @"MoreLanguageDemo", [NSBundle mainBundle], nil));
    
    NSLog(@"=================");
    
    NSLog(@"%@", MoreLanguageString(@"titleLabel", @"zh-Hans"));
    NSLog(@"%@", MoreLanguageString(@"titleLabel", @"en"));
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
